#!/usr/bin/env python
# encoding: utf-8
"""
@author: shura
@position: saber
@contact: 2209032305@qq.com
@file: url.py
@time: 2019/3/9 11:01
@desc:
"""
T = int(input())
urls = []
for _ in range(T):
    line = input()
    res = ""
    j = len(line)-1
    while j >= 0:
        if line[j] == '%':
            if j+3 <= len(line):
                line = line[:j] + chr(int(line[j+1:j+3], 16)) + line[j+3:]
            else:
                line = line[:j] + int(line[j+1:], 16)
            j = len(line)-1
        else:
            j -= 1
    print(line)